import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';

import { GlobalSettingService } from '../services/global-setting.service';

@Injectable()
export class TransactionService {

  constructor(private http: HttpClient, private globalSetting: GlobalSettingService) { }

  public getMyShelf(id: string): any {
    return this.http.get(this.globalSetting.getLibraryWebApiRootUrl() + 'Transaction/GetMyShelf', {
      params: { readerId: id }
    });
  }

  public addBookShelf(bookid: string, readerid: string): any {
    return this.http.get(this.globalSetting.getLibraryWebApiRootUrl() + 'Transaction/AddBookShelf', {
      params: { readerId: readerid, bookId: bookid }
    });
  }

  public removeBookFromShelf(bookid: string, readerid: string): any {
    return this.http.get(this.globalSetting.getLibraryWebApiRootUrl() + 'Transaction/RemoveBookFromShelf', {
      params: { readerId: readerid, bookId: bookid }
    });
  }

  public removeMyShelf(id: string): any {
    return this.http.get(this.globalSetting.getLibraryWebApiRootUrl() + 'Transaction/RemoveMyShelf', {
      params: { readerId: id }
    });
  }

  public submitOrder(id: string): any {
    return this.http.post(this.globalSetting.getLibraryWebApiRootUrl() + 'Transaction/SubmitOrder', {
      readerId: id
    });
  }

  public getBorrowRecords(id: string): any {
    return this.http.get(this.globalSetting.getLibraryWebApiRootUrl() + 'Transaction/GetBorrowRecords', {
      params: { readerId: id }
    });
  }

}
